#include<iostream>
#include<string>
using namespace std;
string s1, s2;
void dfs(int l1, int r1, int l2, int r2)
{
	if(r1<l1) return;
	int i=l1;
	while(s1[i]!=s2[l2]) i++;
	dfs(l1, i-1, l2+1, l2+i-l1);
	dfs(i+1, r1, l2+i-l1+1, r2);
	cout<<s2[l2];
}

int main()
{
	cin>>s1>>s2;
	dfs(0, s1.size()-1, 0, s2.size()-1);
	return 0;
}
